<template>
  <div>
    <MyHeader title="Tabbar案例"></MyHeader>
    <div class="main">
      <component :is="ComName"> </component>
    </div>
    <MyTabbar :tabs="tabList" @changeBar="changeFn"></MyTabbar>
  </div>
</template>

<script>
import MyHeader from "./components/MyHeader";
import MyTabbar from "./components/MyTabbar";
import MyGoodsList from "./views/MyGoodsList";
import Search from "./views/Search";
import UserInfo from "./views/UserInfo";
export default {
  methods: {
    changeFn(index) {
      this.ComName = this.tabList[index].componentName;
    },
  },
  components: {
    MyHeader,
    MyTabbar,
    MyGoodsList,
    Search,
    UserInfo,
  },
  data() {
    return {
      ComName: "MyGoodsList",
      tabList: [
        {
          iconText: "icon-shangpinliebiao",
          text: "商品列表",
          componentName: "MyGoodsList",
        },
        {
          iconText: "icon-sousuo",
          text: "商品搜索",
          componentName: "Search",
        },
        {
          iconText: "icon-user",
          text: "我的信息",
          componentName: "UserInfo",
        },
      ],
    };
  },
};
</script>

<style scoped>
.main {
  padding: 45px 0 50px 0;
}
</style>